package com.soft.mainsite.mybatis.mapper;

import com.soft.mainsite.mybatis.model.TSysUserRole;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * TSysUserRoleMapper
 *
 * @author Jin
 * @create 2017-06-16
 **/
public interface TSysUserRoleMapper {

    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * 保存
     *
     * @param record
     * @return
     */
    int insert(TSysUserRole record);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    TSysUserRole selectByPrimaryKey(Integer id);

    /**
     * 查询所有
     *
     * @return
     */
    List<TSysUserRole> selectAll();

    /**
     * 更新
     *
     * @param record
     * @return
     */
    int updateByPrimaryKey(TSysUserRole record);

    /**
     * 根据用户id和角色id删除
     *
     * @param userId
     * @param roleId
     * @return
     */
    @Delete("DELETE FROM t_sys_user_role where user_id = #{userId} and role_id=#{roleId}")
    int deleteByUserIdAndRoleId(@Param("userId") Integer userId, @Param("roleId") Integer roleId);

    /**
     * 根据用户id删除
     *
     * @param userId
     * @return
     */
    int deleteByUserId(@Param("userId") Integer userId);
}